/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements.  See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License.  You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
 * Project  : WebQQCore
 * Package  : iqq.im.module
 * File     : CoreModule.java
 * Author   : solosky < solosky772@qq.com >
 * Created  : 2012-7-31
 * License  : Apache License 2.0
 */
package iqq.mk.module;

import iqq.im.QQActionListener;
import iqq.mk.action.GetCaptchaImageAction;
import iqq.im.event.QQActionFuture;
import iqq.im.module.AbstractModule;
import iqq.mk.action.CapUnionGetImageAction;
import iqq.mk.action.CapUnionGetSigNewAction;
import iqq.mk.action.CapUnionVerifyNewAction;
import iqq.mk.action.CheckMKRCodeAction;
import iqq.mk.action.CheckVerifyAction;
import iqq.mk.action.GetLoginSigAction;
import iqq.mk.action.GetMKRCodeAction;
import iqq.mk.action.WebLoginAction;
import iqq.mk.action.WebLoginNewAction;

/**
 * 登录模块，处理登录和退出
 *
 * @author solosky
 */
public class LoginModule extends AbstractModule {   

    /**
     * <p>get QRCode</p>
     *
     * @param listener a {@link iqq.im.QQActionListener} object.
     * @return a {@link iqq.im.event.QQActionFuture} object.
     */
    public QQActionFuture getMKRCode(QQActionListener listener) {
        return pushHttpAction(new GetMKRCodeAction(getContext(), listener));
    }
    /**
     * <p>check QRCode</p>
     *
     * @param listener a {@link iqq.im.QQActionListener} object.
     * @return a {@link iqq.im.event.QQActionFuture} object.
     */
    public QQActionFuture checkMKRCode(QQActionListener listener) {
        return pushHttpAction(new CheckMKRCodeAction(getContext(), listener));
    }
    /**
     * <p>getLoginSig.</p>
     *
     * @param listener a {@link iqq.im.QQActionListener} object.
     * @return a {@link iqq.im.event.QQActionFuture} object.
     */
    public QQActionFuture getLoginSig(QQActionListener listener) {
    	return pushHttpAction(new GetLoginSigAction(getContext(), listener));
    }    
    /**
     * <p>checkVerify.</p>
     *
     * @param qqAccount a {@link java.lang.String} object.
     * @param listener  a {@link iqq.im.QQActionListener} object.
     * @return a {@link iqq.im.event.QQActionFuture} object.
     */
    public QQActionFuture checkVerify(String qqAccount, QQActionListener listener) {
        return pushHttpAction(new CheckVerifyAction(getContext(), listener, qqAccount));
    }
    /**
     * <p>getCaptcha.</p>
     *
     * @param uin      a long.
     * @param listener a {@link iqq.im.QQActionListener} object.
     * @return a {@link iqq.im.event.QQActionFuture} object.
     */
    public QQActionFuture getCaptcha(long uin, QQActionListener listener) {
        return pushHttpAction(new GetCaptchaImageAction(getContext(), listener, uin));
    }
    /**
     * new login action,but not worked
     * @param verifyCode
     * @param listener
     * @return
     */
    public QQActionFuture getSigNew(QQActionListener listener) {
    	return pushHttpAction(new CapUnionGetSigNewAction(getContext(), listener));
	}
    public QQActionFuture getCapUnionImage(QQActionListener listener) {
        return pushHttpAction(new CapUnionGetImageAction(getContext(), listener));
    }
    public QQActionFuture capUnionVerifyNew(String verifyCode, QQActionListener listener) {
        return pushHttpAction(new CapUnionVerifyNewAction(getContext(), listener,verifyCode));
    }
    
    /**
     * <p>webLogin.</p>
     *
     * @param username   a {@link java.lang.String} object.
     * @param password   a {@link java.lang.String} object.
     * @param uin        a long.
     * @param verifyCode a {@link java.lang.String} object.
     * @param listener   a {@link iqq.im.QQActionListener} object.
     * @return a {@link iqq.im.event.QQActionFuture} object.
     */
    public QQActionFuture webLogin(String username, String password, long uin, String verifyCode, QQActionListener listener) {
        return pushHttpAction(new WebLoginAction(getContext(), listener, username, password, uin, verifyCode));
    }
    public QQActionFuture ipWebLogin(String username, String password, long uin, String verifyCode, QQActionListener listener) {
        return pushHttpAction(new WebLoginNewAction(getContext(), listener, username, password, uin, verifyCode));
    }
    
}
